Clover coverage report - bexee - 0.1
Coverage timestamp: Do Dez 16 2004 13:24:06 CET
file stats: LOC: 227   Methods: 15
NCLOC: 69   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
ProcessContext.java 50% 95.8% 93.3% 90.7%
coverage coverage
 1   
 /*
 2   
  * $Id: ProcessContext.java,v 1.1 2004/12/15 14:18:10 patforna Exp $
 3   
  *
 4   
  * Copyright (c) 2004 Patric Fornasier, Pawel Kowalski
 5   
  * Berne University of Applied Sciences
 6   
  * School of Engineering and Information Technology
 7   
  * All rights reserved.
 8   
  */
 9   
 package bexee.core;
 10   
 
 11   
 import java.io.Serializable;
 12   
 import java.util.HashMap;
 13   
 import java.util.Map;
 14   
 import java.util.Set;
 15   
 
 16   
 import bexee.event.Event;
 17   
 import bexee.model.activity.Activity;
 18   
 import bexee.model.elements.Variable;
 19   
 
 20   
 /**
 21   
  * The ProcessContext contains state information about a very specific process
 22   
  * instance. This includes:
 23   
  * <ul>
 24   
  * <li>Link states</li>
 25   
  * <li>Global and local variable values</li>
 26   
  * <li>Detailed event information about each processed activity. This
 27   
  * information is vital for the <code>ProcessController</code> to be able to
 28   
  * resume asynchronous process execution. Another optional use of this
 29   
  * information might be a later process execution tracing (e.g. for graphical
 30   
  * representations of an executing or finished process).</li>
 31   
  * </ul>
 32   
  * <p>
 33   
  * The <code>ProcessContext</code> need to be made persistent for later
 34   
  * retrieval of asynchronous or long-running processes.
 35   
  * 
 36   
  * @version $Revision: 1.1 $, $Date: 2004/12/15 14:18:10 $
 37   
  * @author Patric Fornasier
 38   
  * @author Pawel Kowalski
 39   
  */
 40   
 public class ProcessContext implements Serializable {
 41   
 
 42   
     private Map variables;
 43   
 
 44   
     private Map events;
 45   
 
 46   
     private Object result;
 47   
 
 48   
     private BexeeMessage currentMessage;
 49   
 
 50   
     private String id;
 51   
 
 52   
     /**
 53   
      * Creates a new <code>ProcessContext</code>.
 54   
      */
 55  26
     public ProcessContext() {
 56  26
         variables = new HashMap();
 57  26
         events = new HashMap();
 58   
     }
 59   
 
 60   
     /**
 61   
      * Get the result of this process instance.
 62   
      * 
 63   
      * @return
 64   
      */
 65  12
     public Object getResult() {
 66  12
         return result;
 67   
     }
 68   
 
 69   
     /**
 70   
      * Provides a place to store the result of BPEL process instance that has
 71   
      * terminated it's execution.
 72   
      * <p>
 73   
      * After setting the result this method will call <code>notify()</code> on
 74   
      * itself to indicate locking threads that the result is available.
 75   
      * 
 76   
      * @param message
 77   
      */
 78  20
     public synchronized void setResult(Object result) {
 79   
 
 80  20
         this.result = result;
 81  20
         this.notify();
 82   
     }
 83   
 
 84   
     /**
 85   
      * Set the current message.
 86   
      * 
 87   
      * @param message
 88   
      */
 89  4
     public void setMessage(BexeeMessage message) {
 90  4
         this.currentMessage = message;
 91   
     }
 92   
 
 93   
     /**
 94   
      * Get the current message.
 95   
      * 
 96   
      * @return currentMessage
 97   
      */
 98  0
     public BexeeMessage getMessage() {
 99  0
         return currentMessage;
 100   
     }
 101   
 
 102   
     /**
 103   
      * Stores the parts of a given <code>Variable</code>.
 104   
      * 
 105   
      * @param variable
 106   
      *            the <code>Variable</code> that will be used as the key
 107   
      * @param parts
 108   
      *            a <code>Map</code> containing the parts associated with the
 109   
      *            given <code>Variable</code>. The part names are used as
 110   
      *            keys in the parts <code>Map</code>.
 111   
      */
 112  10
     public void setVariable(Variable variable, Map parts) {
 113  10
         variables.put(variable, parts);
 114   
     }
 115   
 
 116   
     /**
 117   
      * Gets the parts associated with a given <code>Variable</code>.
 118   
      * 
 119   
      * @param variable
 120   
      *            the <code>Variable</code> that will be used as the key
 121   
      * 
 122   
      * @return a <code>Map</code> containing the parts associated with the
 123   
      *         given <code>Variable</code>. The part names are used as keys
 124   
      *         in the returned <code>Map</code>.
 125   
      */
 126  38
     public Map getVariable(Variable variable) {
 127  38
         return (Map) variables.get(variable);
 128   
     }
 129   
 
 130   
     /**
 131   
      * It is possible to retrieve all variable identifiers included in this
 132   
      * context (Variable class instances).
 133   
      * 
 134   
      * @return set a Set of <code>Variable</code> instances.
 135   
      */
 136  2
     public Set getVariablesIdentifiers() {
 137  2
         return variables.keySet();
 138   
     }
 139   
 
 140   
     /**
 141   
      * Set a variable part identified by a <code>Variable</code> identifier
 142   
      * and a part name.
 143   
      * 
 144   
      * @param variable
 145   
      *            the variable identifier
 146   
      * @param part
 147   
      *            the part name
 148   
      * @param value
 149   
      *            part value
 150   
      */
 151  6
     public void setVariablePart(Variable variable, String part, Object value) {
 152  6
         Map parts = getVariable(variable);
 153  6
         if (parts == null) {
 154  6
             parts = new HashMap();
 155   
         }
 156  6
         parts.put(part, value);
 157  6
         setVariable(variable, parts);
 158   
     }
 159   
 
 160   
     /**
 161   
      * Get a variable part identified by a <code>Variable</code> identifier
 162   
      * and a part name.
 163   
      * 
 164   
      * @param variable
 165   
      *            the variable identifier
 166   
      * @param part
 167   
      *            the part name
 168   
      * @return value
 169   
      */
 170  6
     public Object getVariablePart(Variable variable, String part) {
 171  6
         Map parts = getVariable(variable);
 172  6
         return parts == null ? null : parts.get(part);
 173   
     }
 174   
 
 175   
     /**
 176   
      * Remove the current message. This method will be called in order to
 177   
      * retrieve the current message and remove it from the
 178   
      * <code>ProcessContext</code> at the same time.
 179   
      * 
 180   
      * @return bexeeMessage a BexeeMessage
 181   
      */
 182  4
     public BexeeMessage removeMessage() {
 183  4
         BexeeMessage message = currentMessage;
 184  4
         currentMessage = null;
 185  4
         return message;
 186   
     }
 187   
 
 188   
     /**
 189   
      * Add an Event to this <code>ProcessContext</code>. The
 190   
      * <code>Event</code> s represent processed activities in bexee. It is
 191   
      * possible to reconstruct states of the process by analyzing those
 192   
      * <code>Event</code>s.
 193   
      * 
 194   
      * @param event
 195   
      */
 196  14
     public void addEvent(Event event) {
 197  14
         events.put(event.getActivity(), event);
 198   
     }
 199   
 
 200   
     /**
 201   
      * Get an <code>Event</code> for the given <code>Activity</code>.
 202   
      * 
 203   
      * @param activity
 204   
      * @return Event
 205   
      */
 206  22
     public Event getEvent(Activity activity) {
 207  22
         return (Event) events.get(activity);
 208   
     }
 209   
 
 210   
     /**
 211   
      * Set the id of this <code>ProcessContext</code>.
 212   
      * 
 213   
      * @param id
 214   
      */
 215  8
     public void setId(String id) {
 216  8
         this.id = id;
 217   
     }
 218   
 
 219   
     /**
 220   
      * Get the id of this <code>ProcessContext</code>.
 221   
      * 
 222   
      * @return
 223   
      */
 224  4
     public String getId() {
 225  4
         return id;
 226   
     }
 227   
 }